home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1544 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.1 KB  |  43 lines

  1. Path: atglab.bls.com!Alun.Champion
  2. From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: cout stupidity
  5. Date: 11 Jan 1996 16:02:28 GMT
  6. Organization: Computer People Inc.
  7. Distribution: world
  8. Message-ID: <ALUN.CHAMPION.96Jan11110228@g7240065.bridge.bst.bls.com>
  9. References: <4d321g$eal@calvin.st-and.ac.uk>
  10. NNTP-Posting-Host: bstfirewall.bst.bls.com
  11. In-reply-to: ks2@st-and.ac.uk's message of 11 Jan 1996 13:06:56 GMT
  12.  
  13. In article <4d321g$eal@calvin.st-and.ac.uk> ks2@st-and.ac.uk (Keith Sibson) writes:
  14.  
  15. :   #include <iostream.h>
  16.  
  17. :   int count=10;
  18.  
  19. :   main()
  20. :   {
  21. :    for(i=0;i<cout;i++) {.....}
  22. :    return(0);
  23. :   }
  24.  
  25. :   Why does this stupidity compile? (BCC 4.5)
  26.  
  27. :   Surely cout is of type ostream? Either there is a dubious operator< that 
  28. :   takes an int and ostream, or there is some wacky automatic conversions going
  29. :   on. Does an ostream cast to an int that is the stream position?
  30.  
  31. The ostream has a
  32.     operator int(void);
  33. defined on it so one can do
  34.     if (cout) {
  35.         blah...;
  36.     }
  37.  
  38. Regards
  39.  
  40.    -A.
  41. -- 
  42. | A.Champion                |
  43.